package com.ems.controller;

import com.ems.service.IDeviceService;
import com.ems.vo.BaseResult;
import com.ems.vo.DeviceVo;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 设备 前端控制器
 * </p>
 * @author WuZH
 * @since 2024-05-08
 */
@RestController
@RequestMapping ("/device")
@CrossOrigin (value = "*", maxAge = 3600)
public class DeviceController {

    @Resource
    private IDeviceService iDeviceService;

    @RequestMapping ("saveSingle")
    public BaseResult saveSingle (@RequestBody DeviceVo deviceVo) {
        deviceVo = iDeviceService.saveSingle ( deviceVo );
        return BaseResult.success ( deviceVo );
    }

    @RequestMapping ("queryList")
    public BaseResult queryList (@RequestBody DeviceVo deviceVo) {
        List<DeviceVo> deviceVos = iDeviceService.queryList ( deviceVo );
        return BaseResult.success ( deviceVos );
    }

    @RequestMapping ("querySingle")
    public BaseResult querySingle (@RequestBody DeviceVo deviceVo) {
        deviceVo = iDeviceService.querySingle ( deviceVo );
        return BaseResult.success ( deviceVo );
    }

}
